home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gigarom 1
/
Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso
/
FILES
/
BBS
/
MUBBS
/
MUBBS etc.cpt
/
Module Source
/
Example2 Module code
/
Some Tests2.c
< prev
Wrap
Text File
|
1991-11-14
|
3KB
|
113 lines
/*
* Some Tests.c
*
* This program source code and it's compiled version is
* Copyright (c) 1991 N. Hawthorn.
* This program source code and it's compiled version IS NOT IN THE
* PUBLIC DOMAIN ! Please read the "COPYRIGHT NOTICE / NH" file for details
* regarding use of this program source code and it's compiled version.
*
*
* Some examples for you...
*
*/
#include "MUBBS Module.h"
struct PPP { /* this struct is NOT created here (globally) ! */
int hahaha; /* this is a test struct to pass some variables to the other */
int hehe; /* test module */
}; /* you DONT HAVE TO USE THIS, just pass 0 to the module in P */
/* and make this a empty struct */
tests(P)
struct PPP *P;
{
char datetime[25];
if (!G->online[u]) goto byebye; /* do this check so we can log out if hang up */
print("This is the Example2 module, module mode is %d.\n",mode[u]);
send("]Hello this is the Example2 module printing something to the user online]");
loop:
if (P != 0L) /* only do this if we are passed a pointer to a something */
{
send("]P->hahaha=%d, P->hehe=%d IN THE MODULE !",P->hahaha,P->hehe);
P->hehe=100; /* change it to show that you can do this ! */
}
loguser(G->modulename[u]); /* this tells where you are for remote sysop, or writes to log file */
/* you print the following so that the sysop can monitor use on the mac screen */
print("C> Line %d %s, at: %s\n",(u+1),G->username[u],G->modulename[u]);
/* this print is for the Example module only */
print("\nC> This module's name is :%s, the calling module's name was :%s ",G->modulename[u],G->oldmodulename[u]);
send("]] *** Example2 Module Menu ***]]");
if (!(cmd1(">> Getdatetime, Remove time, Sendafile, Time on, Quit :"))) goto byebye; /* timeout */
send (G->CR[u]);
switch (G->input[u]) {
case 'G':
getdatetime(datetime); /* gets the date & time */
send("]You are on line %d at %s PST]", (u+1), datetime);
break;
case 'R':
send("]Time WAS %d minutes so far, %d allowed]",G->timeon[u],G->timeallowed[u]);
if(G->timeallowed[u] > 5) { G->timeallowed[u]=5;} /* test the timeout in the menu module */
G->timeon[u]++;
send("]Time adjusted to %d minutes so far, %d allowed]",G->timeon[u],G->timeallowed[u]);
break;
case 'S':
send("]a test of open, sending \":testtext:test.txt\"]");
sendafile(":testtext:test.txt"); /* send this file in this folder */
break;
case 'T':
send("]You have been on line %d minutes so far, %d allowed]",G->timeon[u],G->timeallowed[u]);
break;
case 'Q': /* Quit */
return;
break;
}
if (!G->online[u]) goto byebye; /* log out */
goto loop;
byebye:
G->online[u]=FALSE; /* show we timed out */
}
sendafile(file) /* this shows you how file access works */
/* this type of fuction is SUPPLIED to you in a call back */
/* this is just for a EXAMPLE ! */
char *file;
{
int i;
unsigned char c;
char temp[64];
FILE *stream;
if ((stream = fopen(file, "r")) == NULL) {
print("\nFILE ERROR, cannot open %s ",file);
send("]FILE ERROR - Cannot open file %s ",file);
return;
}
else print("\nopened %s ",file);
strcpy(temp,"Viewing ");
strcat(temp,file);
loguser(temp);
while (((i = fgetc(stream)) != EOF)) {
if (G->okcancel[u]) {if (G->cancel[u]) break;} /* check for cancel press */
c = i & 0xFF;
if ((c == 0x0A) || (c == 0x0D)) { send(G->CR[u]); }
else G->out(c);
}
fclose(stream);
G->cont[u]=FALSE; /* set for term line counting, incase they pressed "continuous" */
}